/*****************************************************************************
*        描述 :
*             文件描述
*        CLR版本:            3.5
*        创建者 :            蒋 光
*        个人域名:           jiangguang.net.cn
*        命名空间名称:       ECP.Utilities
*        文件名:             BaseSystemInfo.cs
*        创建系统时间:       2012/11/2 19:07:08
*        创建年份:           2012
*
/*****************************************************************************/

namespace ECP.Utilities
{
    using System;
    using System.Management;
    using System.Net;

    public class BaseSystemInfo
    {
        public static bool AllowNullPassword = true;
        public static string AppIco = string.Empty;
        public static string AppPath = System.Windows.Forms.Application.StartupPath;
        public static string BugFeedback = "mailto:JiRiGaLa@HotMail.com?subject=对费用报销管理的反馈&body=这里输入您宝贵的反馈";
        public static bool CheckIPAddress = false;
        public static bool CheckMACAddress = false;
        public static bool CheckOnLine = false;
        public static bool CheckOnLineLimit = false;
        public static bool ClientCache = false;
        public static string Code = string.Empty;
        public static string CompanyFullName = "一心一意";
        public static string CompanyPhone = "15062423834";
        public static string ConfigPassword = "sa";
        public static string ConfigUsername = "sa";
        public static string Copyright = "Copyright 2004-2008 jiangguang.net.cn Corporation";
        public static string Culture = "zh-CN";
        public static string CurrentLanguage = string.Empty;
        public static string CustomerPhone = "+86-15062423834";
        public static string DateFormat = "yyyy-MM-dd";
        public static string DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
        public static bool EncryptPassword = false;
        public static string ErrorReportMailAddress = "552152867@qq.com";
        public static string ErrorReportMailServer = "smtp.qq.com";
        public static string ErrorReportPassword = "552152867";
        public static string ErrorReportTo = "552152867@qq.com";
        public static string ErrorReportUsername = "552152867@qq.com";
        public static bool EventLog = false;
        public static string FormIco = string.Empty;
        public static string HelpNamespace = string.Empty;
        public static string IEDownloadUrl = "http://download.microsoft.com/download/ie6sp1/finrel/6_sp1/W98NT42KMeXP/CN/ie6setup.exe";
        public static string IPAddress = string.Empty;
        public static bool IsAdministrator = false;
        public static string LastUpdate = "2012.11.22";
        public static int LockNoWaitCount = 5;
        public static int LockNoWaitTickMilliSeconds = 30;
        public static bool LogException = true;
        public static bool Logined = false;
        public static bool LogSQL = false;
        public static string MACAddress = string.Empty;
        public static string MainAssembly = string.Empty;
        public static bool MatchCase = true;
        public static bool NeedLogin = false;
        public static bool NeedRegister = false;
        public static int OnLineCheck = 60;
        public static int OnLineLimit = 0;
        public static int OnLineTime0ut = 180;
        public static string Password = string.Empty;
        public static string ProcessID = string.Empty;
        public static string ProcessName = string.Empty;
        public static bool RecordLoginLog = true;
        public static string Role = string.Empty;
        public static string RoleFullName = string.Empty;
        public static bool SavePassword = true;
        public static bool ServerCache = false;
        public static bool ShowInformation = true;
        public static string StaffID = string.Empty;
        public static string StartupPath = string.Empty;
        public static string SUID = string.Empty;
        public static string Themes = string.Empty;
        public static string TimeFormat = "HH:mm:ss";
        public static int TopLimit = 200;
        public static bool UpdateVisit = true;
        public static string UploadDirectory = "Document/";
        public static string UserCompanyCode = string.Empty;
        public static string UserCompanyFullName = string.Empty;
        public static string UserCompanyID = string.Empty;
        public static string UserDepartmentCode = string.Empty;
        public static string UserDepartmentFullName = string.Empty;
        public static string UserDepartmentID = string.Empty;
        public static string UserID = string.Empty;
        public static string Username = string.Empty;
        public static string UserRealname = string.Empty;
        public static string Version = "1.2";
        public static string WebProxy = string.Empty;
        public static string WebServicePassword = "ShowLight";
        public static string WebServiceUsername = "ShowLight";
        public static bool GetChildrensByCode = false;

        public static string GetCPUSerialNo()
        {
            string str = string.Empty;
            ManagementClass class2 = new ManagementClass("Win32_Processor");
            foreach (ManagementObject obj2 in class2.GetInstances())
            {
                return obj2.Properties["ProcessorId"].Value.ToString();
            }
            return str;
        }

        public static string GetHardDiskInfo()
        {
            string str = string.Empty;
            ManagementClass class2 = new ManagementClass("Win32_DiskDrive");
            foreach (ManagementObject obj2 in class2.GetInstances())
            {
                return (string)obj2.Properties["Model"].Value;
            }
            return str;
        }

        public static string GetIPAddress()
        {
            return Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString();
        }

        public static string GetMacAddress()
        {
            string str = string.Empty;
            ManagementClass class2 = new ManagementClass("Win32_NetworkAdapterConfiguration");
            foreach (ManagementObject obj2 in class2.GetInstances())
            {
                if ((bool)obj2["IPEnabled"])
                {
                    return obj2["MacAddress"].ToString();
                }
            }
            return str;
        }

        public static BaseUserInfo Login(BaseUserInfo userInfo)
        {
            if (userInfo != null)
            {
                SUID = userInfo.SUID;
                UserID = userInfo.ID;
                StaffID = userInfo.StaffID;
                Username = userInfo.Username;
                UserRealname = userInfo.Realname;
                Code = userInfo.Code;
                Role = userInfo.Role;
                RoleFullName = userInfo.RoleFullName;
                Password = userInfo.Password;
                UserCompanyID = userInfo.CompanyID;
                UserCompanyCode = userInfo.CompanyCode;
                UserCompanyFullName = userInfo.CompanyFullName;
                UserDepartmentID = userInfo.DepartmentID;
                UserDepartmentCode = userInfo.DepartmentCode;
                UserDepartmentFullName = userInfo.DepartmentFullName;
                IsAdministrator = userInfo.IsAdministrator;
            }
            return userInfo;
        }

        public static string CommonWebService
        {
            get
            {
                return BaseConfiguration.Instance.CommonWebService;
            }
            set
            {
                BaseConfiguration.Instance.CommonWebService = value;
            }
        }

        public static string CustomerCompanyName
        {
            get
            {
                return BaseConfiguration.Instance.CustomerCompanyName;
            }
        }

        public static string DbConnectionString
        {
            get
            {
                return BaseConfiguration.Instance.DbConnectionString;
            }
            set
            {
                BaseConfiguration.Instance.DbConnectionString = value;
            }
        }

        public static string FileWebService
        {
            get
            {
                return BaseConfiguration.Instance.FileWebService;
            }
            set
            {
                BaseConfiguration.Instance.FileWebService = value;
            }
        }

        public static bool RecordLog
        {
            get
            {
                return BaseConfiguration.Instance.RecordLog;
            }
            set
            {
                BaseConfiguration.Instance.RecordLog = value;
            }
        }

        public static string RootMenuID
        {
            get
            {
                return BaseConfiguration.Instance.RootMenuID;
            }
        }

        public ECP.Utilities.RunMode RunMode
        {
            get
            {
                return BaseConfiguration.Instance.RunMode;
            }
            set
            {
                BaseConfiguration.Instance.RunMode = value;
            }
        }

        public static string SoftFullName
        {
            get
            {
                return BaseConfiguration.Instance.SoftFullName;
            }
        }

        public string SoftName
        {
            get
            {
                return BaseConfiguration.Instance.SoftName;
            }
            set
            {
                BaseConfiguration.Instance.SoftName = value;
            }
        }

        public static bool UseLicensedPermission
        {
            get
            {
                return BaseConfiguration.Instance.UseLicensedPermission;
            }
            set
            {
                BaseConfiguration.Instance.UseLicensedPermission = value;
            }
        }

        public static BaseUserInfo UserInfo
        {
            get
            {
                if (string.IsNullOrEmpty(UserID))
                {
                    UserID = GetIPAddress();
                }
                if (string.IsNullOrEmpty(Username))
                {
                    Username = Environment.MachineName;
                }
                if (string.IsNullOrEmpty(UserRealname))
                {
                    UserRealname = Environment.UserName;
                }
                return new BaseUserInfo
                {
                    SUID = SUID,
                    ID = UserID,
                    StaffID = StaffID,
                    Username = Username,
                    Realname = UserRealname,
                    Role = Role,
                    RoleFullName = RoleFullName,
                    CompanyID = UserCompanyID,
                    CompanyCode = UserCompanyCode,
                    CompanyFullName = UserCompanyFullName,
                    DepartmentID = UserDepartmentID,
                    DepartmentCode = UserDepartmentCode,
                    DepartmentFullName = UserDepartmentFullName,
                    CurrentLanguage = CurrentLanguage,
                    Themes = Themes,
                    IPAddress = IPAddress,
                    WebServiceUsername = WebServiceUsername,
                    WebServicePassword = WebServicePassword
                };
            }
        }

        public static bool UseScopeAdmin
        {
            get
            {
                return BaseConfiguration.Instance.UseScopeAdmin;
            }
            set
            {
                BaseConfiguration.Instance.UseScopeAdmin = value;
            }
        }

        public static string WebService
        {
            get
            {
                return BaseConfiguration.Instance.WebService;
            }
            set
            {
                BaseConfiguration.Instance.WebService = value;
            }
        }

        public static string WorkReportWebService
        {
            get
            {
                return BaseConfiguration.Instance.WorkReportWebService;
            }
            set
            {
                BaseConfiguration.Instance.WorkReportWebService = value;
            }
        }

        public static string Service { get; set; }

        public static string ServiceUsername { get; set; }

        public static string ServicePassword { get; set; }
    }
}